package com.jl.jlapp.mvp.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.jl.jlapp.R;
import com.jl.jlapp.adapter.EvalDetailAdapter;
import com.jl.jlapp.adapter.EvalDetailAdapter.OnClickGoodsPicItemListener;
import com.jl.jlapp.eneity.OrderEvaluationDetailModel;
import com.jl.jlapp.eneity.OrderEvaluationDetailModel.ResultDataBean;
import com.jl.jlapp.eneity.OrderEvaluationDetailModel.ResultDataBean.OrderDetailsBean;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.utils.CustomLanearLayoutManager;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.util.List;

public class EvaluationDetailActivity
        extends Activity
        implements OnClickGoodsPicItemListener {
    @BindView(R.id.back)
    ImageView back;
    EvalDetailAdapter evalDetailAdapter;
    @BindView(R.id.evaluation_detail_recycler_view)
    RecyclerView evaluationDetailRecyclerView;
    List<OrderEvaluationDetailModel.ResultDataBean.OrderDetailsBean> orderDetailsBeans;
    int orderId = 0;
    OrderEvaluationDetailModel.ResultDataBean resultDataBean;
    int userId = 0;

    public void OnClickGoodsPicItem(String paramString) {
        Intent localIntent = new Intent(this, PhotoViewActivity.class);
        localIntent.putExtra("picUrl", paramString);
        startActivity(localIntent);
    }

    public void getEvaluationDetailByUserIdAndOrderId(Integer paramInteger1, Integer paramInteger2) {
        Net.get().getEvaluationDetailByUserIdAndOrderId(paramInteger2.intValue(), paramInteger1.intValue())
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
                .subscribe(new CommonObserver<OrderEvaluationDetailModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(OrderEvaluationDetailModel orderEvaluationDetailModel) {

                    }
                });
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.activity_evaluation_detail);
        ButterKnife.bind(this);
        this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", 0);
        this.back.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                EvaluationDetailActivity.this.finish();
            }
        });
        if (this.userId > 0) {
            this.orderId = getIntent().getIntExtra("orderId", 0);
            if (this.orderId > 0) {
                getEvaluationDetailByUserIdAndOrderId(Integer.valueOf(this.userId), Integer.valueOf(this.orderId));
            } else {
                Toast.makeText(this, "抱歉，数据出错。", Toast.LENGTH_SHORT).show();
            }
        } else {
            Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(this, LoginActivity.class));
        }
    }

    public void setAdapter() {
        if (this.evalDetailAdapter == null) {
            this.evaluationDetailRecyclerView.setLayoutManager(new CustomLanearLayoutManager(this, false));
            this.evalDetailAdapter = new EvalDetailAdapter(R.layout.evaluation_submit_success_item, this.orderDetailsBeans);
            this.evalDetailAdapter.setOnClickGoodsPicItemListener(this);
            this.evaluationDetailRecyclerView.setAdapter(this.evalDetailAdapter);
            return;
        }
        this.evalDetailAdapter.notifyDataSetChanged();
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/EvaluationDetailActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */